package eerbaar.internal.expression;

import java.util.HashMap;
import java.util.Map;

import eerbaar.context.IParams;
import eerbaar.expression.IExpression;
import eerbaar.expression.IExpressionFactory;
import eerbaar.expression.IExpressionService;

public class ExpressionService implements IExpressionService {

    private final Map<String, IExpressionFactory> expressions = new HashMap<String, IExpressionFactory>();

    @Override
    public IExpression createExpression(String name, IParams params) {

        IExpressionFactory f = this.expressions.get(name);
        if (f == null) {
            System.out.println("not found " + name);
        }
        assert (f != null) : "not found " + name;
        return f.create(params);
    }

    @Override
    public void registerExpression(String name, IExpressionFactory expression) {

        this.expressions.put(name, expression);
    }

}
